package club.babyf.nativeai.controller;

import club.babyf.nativeai.common.BaseResponse;
import club.babyf.nativeai.service.IFileParserService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * FileController.
 *
 * @author zhanglei.
 * @date 2025/3/17 10:43.
 * @description 文件控制器.
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/native-ai/file")
public class FileController {

    private final IFileParserService fileParserService;

    /**
     * 文件解析
     *
     * @param file 文件
     * @return 解析结果
     */
    @PostMapping("/parse")
    public ResponseEntity<Object> parse(@RequestParam("file") MultipartFile file) {
        return BaseResponse.ok(fileParserService.parse(file));
    }

    /**
     * 文件解析分块
     *
     * @param file 文件
     * @return 解析分块结果
     */
    @PostMapping("/parse-split")
    public ResponseEntity<Object> parseSplit(@RequestParam("file") MultipartFile file) {
        return BaseResponse.ok(fileParserService.parseSplit(file));
    }

}
